/*
 *    Copyright 2006-2020 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.mybatis.generator.api.dom.java;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class TopLevelEnumeration extends InnerEnum implements CompilationUnit {

	private final Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>();

	private final Set<String> staticImports = new TreeSet<>();

	private final List<String> fileCommentLines = new ArrayList<>();

	public TopLevelEnumeration(FullyQualifiedJavaType type) {
		super(type);
	}

	public TopLevelEnumeration(String type) {
		super(type);
	}

	@Override
	public Set<FullyQualifiedJavaType> getImportedTypes() {
		return importedTypes;
	}

	@Override
	public void addImportedType(FullyQualifiedJavaType importedType) {
		if (importedType.isExplicitlyImported() && !importedType.getPackageName().equals(getType().getPackageName())) {
			importedTypes.add(importedType);
		}
	}

	@Override
	public void addFileCommentLine(String commentLine) {
		fileCommentLines.add(commentLine);
	}

	@Override
	public List<String> getFileCommentLines() {
		return fileCommentLines;
	}

	@Override
	public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
		this.importedTypes.addAll(importedTypes);
	}

	@Override
	public Set<String> getStaticImports() {
		return staticImports;
	}

	@Override
	public void addStaticImport(String staticImport) {
		staticImports.add(staticImport);
	}

	@Override
	public void addStaticImports(Set<String> staticImports) {
		this.staticImports.addAll(staticImports);
	}

	@Override
	public <R> R accept(CompilationUnitVisitor<R> visitor) {
		return visitor.visit(this);
	}
}
